/**
 * @Author: lifuzhao
 * @Date: 2019-07-11
 * @Project: driver
 */
import Vue from 'vue'
import Router from 'vue-router'
import defaultLayout from '../layouts/default'
import Guard from './Guard'

Vue.use(Router)
const _guard = new Guard()
const _router = new Router({
  mode: 'hash',
  base: process.env.BASE_URL,
  routes: [
    {
      path: '/'
      , name: 'home'
      , component: defaultLayout
      , redirect: '/order'
      , children: [
        {
          path: '/order'
          // route level code-splitting
          // this generates a separate chunk (about.[hash].js) for this route
          // which is lazy-loaded when the route is visited.
          , component: () => import(/* webpackChunkName: "order" */ '../views/order/')
          , meta: {
            title: '订单记录'
          }
        }
        , {
          path: '/driver/onlineStats'
          , component: () => import(/* webpackChunkName: "online-stats" */ '../views/driver/onlineStats')
          , meta: {
            title: '在线统计'
            , auth: [1, 3]
          }
        }
        , {
          path: '/driver/accountManage'
          , component: () => import(/* webpackChunkName: "account-manage" */ '../views/driver/accountManage')
          , meta: {
            title: '账号管理'
            , auth: [1, 3]
          }
        }
        , {
          path: '/userManage'
          , component: () => import(/* webpackChunkName: "user-manage" */ '../views/userManage/index')
          , meta: {
            title: '用户管理'
            , auth: [1, 3]
          }
        }
        , {
          path: '/hotel/list'
          , component: () => import(/* webpackChunkName: "hotel-list" */ '../views/hotel/list')
          , meta: {
            title: '酒店列表'
            , auth: [1]
          }
        }
        , {
          path: '/hotel/order'
          , component: () => import(/* webpackChunkName: "hotel-order" */ '../views/hotel/order')
          , meta: {
            title: '酒店订单'
            , auth: [1]
          }
        }
        , {
          path: '/franchisee'
          , component: () => import(/* webpackChunkName: "franchisee-manage" */ '../views/franchisee/index')
          , meta: {
            title: '代理商管理',
            auth: [1, 3]
          }
        }
        , {
          path: '/coupon/setting'
          , component: () => import(/* webpackChunkName: "coupon-setting" */ '../views/coupon/setting')
          , meta: {
            title: '卡劵设置'
            , auth: [1, 3]
          }
        }
        , {
          path: '/coupon/distribution'
          , component: () => import(/* webpackChunkName: "coupon-distribution" */ '../views/userManage/index')
          , meta: {
            title: '派发记录'
            , auth: [1, 3]
          }
        }
        , {
          path: '/charge'
          , component: () => import(/* webpackChunkName: "charge-index" */ '../views/charge/index')
          , meta: {
            title: '服务费设置'
            , auth: [1, 3]
          }
        }
        , {
          path: '/permission/manage'
          , component: () => import(/* webpackChunkName: "permission-manage" */ '../views/permission/manage')
          , meta: {
            title: '权限管理'
            , auth: [1, 3]
          }
        }
        , {
          path: '/announcement/manage'
          , component: () => import(/* webpackChunkName: "announcement-manage" */ '../views/announcement/manage')
          , meta: {
            title: '公告管理'
            , auth: [1, 3]
          }
          , children: [
            {
              path: '/announcement/manage/edit/:id'
              , component: () => import(/* webpackChunkName: "announcement-edit" */ '../views/announcement/parts/edit')
              , meta: {
                title: '公告管理'
                , auth: [1, 3]
              }
            }
          ]
        }, {
          path: '/feedback'
          , component: () => import(/* webpackChunkName: "feedback-index" */ '../views/feedback/index')
          , meta: {
            title: '用户反馈'
            , auth: [1, 3]
          }
        }, {
          path: '/shortMessage',
          component: () => import(/* webpackChunkName: "shortMessage-index" */ '../views/shortMessage/index'),
          meta: {
            title: '短信管理',
            auth: [1, 3]
          }
        }, {
          path: '/shortMessage/rechargeRecord',
          component: () => import(/* webpackChunkName: "shortMessage-index" */ '../views/shortMessage/rechargeRecord'),
          meta: {
            title: '充值记录',
            auth: [1, 3]
          }
        }, {
          path: '/shortMessage/rechargeTemplate',
          component: () => import(/* webpackChunkName: "shortMessage-rechargeTemplate" */ '../views/shortMessage/rechargeTemplate'),
          meta: {
            title: '充值模板',
            auth: [3]
          }
        }
      ]
    }
    , {
      path: '/login'
      , name: 'login'
      , component: () => import(/* webpackChunkName: "login" */ '../views/login.vue')
      , meta: {
        title: '登录'
      }
    }
    , {
      path: '/driver/location'
      , component: () => import(/* webpackChunkName: "driver-location" */ '../views/driver/location')
      , meta: {
        title: '地理位置'
        , auth: [1, 3]
      }
    }
  ]
})
_router.beforeEach(_guard.beforeEach)
export default _router
